package com.wtwd.campus.service;


import com.wtwd.campus.entity.SysUser;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * @author mjy
 * @date 2021/06/08
 * @description
 */
public interface RedisService {
    //创建token
    void createToken(SysUser sysUser, String token);

    //设置key值
    void setKey(String key, String value, long expireTime, TimeUnit timeUnit);

    void setHash(String key, Map<String, Object> map, long expireTime, TimeUnit timeUnit);

    void setHash2(String key, Map<String, Object> map, long expireTime, TimeUnit timeUnit);

    void setHash3(String key, Map<String, Object> map, long expireTime, TimeUnit timeUnit);

    Map<String, Object> getHash(String key);

    //获取token里面的用户数据
    Map<String, Object> getUserInfoByToken(String token);

    // 判断键是否存在
    boolean hasKey(String key);

    /**
     * 根据前缀模糊查询
     */
    List getValuesByLikePrefix(String Prefix);

    /**
     * 创建客户token
     *
     * @param customerId
     * @return String[0]-AccessToken  String[1]-refreshToken
     */
    String[] createCustomerToken(Integer customerId);

    String getValue(String key);

    void deleteCommand(String imei, String index);


    /**
     * 根据前缀删除hash值
     *
     * @param imei
     * @param cmdPrefix
     */
    void deleteHashByPrefix(String imei, String cmdPrefix);

    boolean verifyRefreshToken(Integer customerId, String refreshToken);

    /**
     * 客户token转客户ID
     *
     * @param accessToken
     * @return
     */
    Integer customerToken2CustomerId(String accessToken);

    Map<String, Object> getCommandsByImei(String imei);

    /**
     * 删除键
     *
     * @param key
     * @return
     */
    boolean deleteKey(String key);

    Map<String, Object> getHashMap(String key);

    void setUnInStorageDevice(String imei);

    void deleteUnInStorageList(List<String> list);

    /**
     * keys xxx 操作
     *
     * @param pattern 匹配模式
     * @return
     */
    Set keys(String pattern);

    /**
     * 创建威科姆类型客户的客户token
     *
     * @param vcomTypeCustomerId
     * @return
     */
    String createVcomTypeToken(Integer vcomTypeCustomerId);

    /**
     * 根据imei获取commandNumber
     *
     * @param imei
     * @return
     */
    long getCommandNumberByImei(String imei);

    /**
     * 根据威科姆类型的客户获取requestId
     *
     * @param vcomTypeCustomerId
     * @return
     */
    String getRequestIdByVcomTypeCustomerId(int vcomTypeCustomerId);

    /**
     * 获取威科姆用户信息
     *
     * @param token
     * @return
     */
    Map<String, Object> getVcomUserInfo(String token);

    /**
     * <p>
     * 此处模糊查询key值主要是用于和设备在线查询
     * <p>
     * 由于设备在线每个
     *
     * @param cmdPrefix
     * @return
     */
    Set<String> getKeysByLikePrefix(String cmdPrefix);

    boolean lock(String key, String value, long expireTime);

    boolean unlock(String key, String value);
}
